<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

<!-- <script>
    let add = (a, b) => a + b;
    let sub = (a, b) => a - b;

    let siZe = function(a, b, fn) {
        return fn(a, b);
    }

    console.log(siZe(2, 1, add));
    console.log(siZe(2, 1, sub));
</script> -->

<!-- <script>
    let max = (a, b) => a > b ? a : b;
    let min = (a, b) => a < b ? a : b;

    let find = function(a, fn) {
        let ret = a[0];
        for (let i = 1; i < a.length; i++) {
            ret = fn(a[i], ret);
        }
        return ret;
    }

    let a = [2, 4, 1, 5, 6, 3];
    console.log(find(a, min));
    console.log(find(a, max));
</script> -->

<script>
    let isOK = (a, b) => a >= b;

    let find = function(a, b, fn) {
        let ret = new Array();
        for (let i = 0; i < a.length; i++) {
            if (fn(a[i], b)) {
                ret.push(a[i]);
            }
        }
        return ret;
    }
    let a = [2, 4, 1, 5, 6, 3];
    console.log(find(a, 3, isOK));
</script>

</html>